<template>
	<!-- allocationshell米券调拨 -->
	<view class="a_wp">
		<view class="a_item">
			<text>调出店铺:</text>
			<picker class="a_selet" :range-key="'supname'" @change="outChange" :range="shoplist">
				<view :class="{'uni-input':outValue.supname=='请选择'}">{{outValue.supname}}</view>
			</picker>
		</view>
		<view class="a_item">
			<text>调入店铺:</text>
			<picker class="a_selet" :range-key="'supname'" @change="inChange" :range="shoplist">
				<view :class="{'uni-input':inValue.supname=='请选择'}">{{inValue.supname}}</view>
			</picker>
		</view>
		<view class="a_item">
			<text>调拨数:（米券）</text>
			<input type="number" class="a_input" v-model="credit" placeholder="请输入调拨米券数" />
		</view>
		<view class="fbt" @click="onshumbit">确认调拨</view>
		<view class="fbt a_record" @click="$navTo('/pages/groupmenu/allocationrecord')">调拨记录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				credit: '',
				
				outValue: {
					supname: "请选择",
					uid: ""
				},
				inValue: {
					supname: "请选择",
					uid: ""
				},
				shoplist: [],
			}
		},
		onLoad() {
			this.getshoplist();
		},
		methods: {
			getshoplist() {
				this.$axios('groupCredit/display', 'POST', 'supplier').then(res => {
					if (res.data.code == 200) {
						this.shoplist= res.data.data;
					}
				})
			},
			onshumbit() {
				if(this.outValue.uid==''||this.inValue.uid==''||this.credit==''){
					this.$api.msg('请完善调拨信息！');
					return ;
				}
				
				var obj={
					fromuid:this.outValue.uid,
					touid:this.inValue.uid,
					credit:this.credit,
				}
				this.$axios('groupCredit/changeCredit', 'POST', 'supplier',obj).then(res => {
					if (res.data.code == 200) {
						this.$api.msg('提交成功！');
						setTimeout(()=>{
							this.$navBack();
						},500)
					}
				})
				
			},
			outChange(e) {
				this.outValue = this.shoplist[e.detail.value];
			},
			inChange(e) {
				this.inValue = this.shoplist[e.detail.value];
			},
		}
	}
</script>

<style lang="scss">
	page {
		color: $font-color-dark;
	}

	.a_wp {
		padding: 20upx;
	}

	.a_item {
		display: flex;
		align-items: center;
		padding: 20upx 0;
	}

	.a_selet {
		flex: 1;
		padding-left: 15upx;
	}

	.uni-input {
		color: $font-color-light;
	}

	.a_input {
		width: 273px;
		border-radius: 4px;
		position: relative;
		font-size: 26upx;
		line-height: 22px;
		height: 36px;
		padding: 0 10upx;
		border: 1px solid hsl(0, 0%, 87%);
	}
	.a_record{
		background-color: $font-color-disabled;
		color: $font-color-dark;
	}
</style>
